<div id="menu" class="index container-fluid">
    <div class="con container">
        <div class="menu">
            <ul>
                {{each categories item index}}
                <li><a href="javascript:;"><i class="{{item.class}}"></i>{{item.name}}</a></li>
                {{/each}}
            </ul>
        </div>
        <a href="javascript:;" class="in"><strong>我要找店</strong>
            <small>Looking for a store</small>
        </a>
        <a href="javascript:;" class="out"><strong>我要转店</strong>
            <small>Attorn my store</small>
        </a>
    </div>
</div>
<script type="text/javascript">
    var $menu = $('.menu');
    var $seek = $('.in');
    var $out = $('.out');
    var cate = [];
    $menu.on('click', 'li', function () {
        var b = $(this).find('a')[0];
        if (b.textContent == '其他转让') {
            cate.push('其他');
        } else {
            cate.push(b.textContent);
        }
        console.log(b.textContent);
        setquery(cate, 'Attorn');
    })
    $seek.on('click', function () {
        setquery(cate, 'Attorn');
    })
    $out.on('click', function () {
        setquery(cate, 'SeekLease');
    })

    function setquery(cate, type) {

        var query;
        if (type == 'Attorn') {
            query = {
                category: cate.length > 0 ? cate : '', // 行业
                infoType: type, // 转让
                estateType: '', // 行业类型
                "estate.district": '', // 行政区
                "estate.shopArea": '', // 商圈
                "estate.subway": '', // 地铁
                "estate.transferFee": '', // 转让费
                "estate.area": '', // 面积
                "estate.rental": '', // 租金
                "estate.type": '', // 商铺类型
                "estate.canEmptyAttorn": '', // 空转
                "estate.canBargaining": '', // 议价
                "site": SITE_ID,
                //   "estate.city":CITY
            }
        } else {
            query = {
                category: cate.length > 0 ? cate : '', // 行业
                infoType: type, // 转让
                estateType: '', // 行业类型
                "estate.district": '', // 行政区
                "estate.shopArea": '', // 商圈
                "estate.transferFee": '', // 转让费
                "estate.subway": '', // 地铁
                "estate.area.max": '', // 面积
                "estate.rental.max": '', // 租金
                "estate.type": '', // 商铺类型
                "estate.canEmptyAttorn": '', // 空转
                "estate.canBargaining": '', // 议价
                "site": SITE_ID,
                //   "estate.city":CITY
            }
        }

        var sort = {
            createdAt: -1
        };

        var page = {
            index: 1,
            size: 20
        }
        setTimeout(function () {
            window.location.href = SITE_ADDR + "/" + CITY + "/list?query=" + JSON.stringify(query) + "&sort=" + JSON.stringify(sort) + "&page=" + JSON.stringify(page);
        }, 200);
    }
</script>
